#include <sys/socket.h>
#include <stdio.h>
#include <stdlib.h>
#include <netinet/ip.h>
#include <strings.h>
#include <stdbool.h>

bool send_all(int sock, const char* buf, size_t size) {
    while (1) {
        ssize_t r = send(sock, buf, size, 0);
        if (r < 0) {
            return false;
        }
        if (r == size) {
            return true;
        }
        buf += r;
        size -= r;
    }
}
